<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      v-show="showSearch"
      label-width="140px"
    >
      <el-form-item label="" prop="channel">
        <el-input
          v-model="queryParams.channel"
          placeholder="请选择渠道"
          clearable
          @keyup.enter.native="handleQuery"
        />
        <!-- <el-select
          v-model="queryParams.channelList"
          placeholder="请选择渠道"
          clearable
          multiple
          filterable
        >
          <el-option
            v-for="(item, index) in channelList"
            :key="index"
            :label="item"
            :value="item"
          >
          </el-option>
        </el-select> -->
      </el-form-item>
      <!-- <el-form-item label="" prop="channel">
        <el-select
          v-model="queryParams.shopList"
          placeholder="请选择店铺"
          clearable
          multiple
          filterable
        >
          <el-option
            v-for="(item, index) in shopList"
            :key="index"
            :label="item"
            :value="item"
          >
          </el-option>
        </el-select>
      </el-form-item> -->
      <el-form-item label="支付日期" prop="dataDate">
        <!-- <el-date-picker
          clearable
          v-model="queryParams.dataDate"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="支付日期"
        >
        </el-date-picker> -->
        <el-date-picker
          v-model="value2"
          type="daterange"
          align="right"
          unlink-panels
          range-separator="-"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
          :picker-options="pickerOptions"
          @change="changeTime"
          size="mini"
        >
        </el-date-picker>
      </el-form-item>
      <!-- <el-form-item label="" prop="">
        <el-date-picker
          clearable
          v-model="queryParams.payDayStart"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="开始日期"
        >
        </el-date-picker>
        <el-date-picker
          clearable
          v-model="queryParams.payDayEnd"
          type="date"
          value-format="yyyy-MM-dd"
          placeholder="结束日期"
        >
        </el-date-picker>
      </el-form-item> -->
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        >
        <el-button
          :icon="!isOpen ? 'el-icon-arrow-down' : 'el-icon-arrow-up'"
          size="mini"
          @click="shouqi"
          >展开/收起</el-button
        >
      </el-form-item>
      <div v-if="isOpen">
        <el-form-item label="销售金额" prop="salesAmount">
          <el-input
            v-model="queryParams.salesAmount"
            placeholder="请输入销售金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="退款金额" prop="returnAmount">
          <el-input
            v-model="queryParams.returnAmount"
            placeholder="请输入退款金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="净销售额" prop="netSalesAmount">
          <el-input
            v-model="queryParams.netSalesAmount"
            placeholder="请输入净销售额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品销售总金额" prop="totalSalesNumber">
          <el-input
            v-model="queryParams.totalSalesNumber"
            placeholder="请输入商品销售总金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发货前退货数" prop="returnBeforeShipmentNumber">
          <el-input
            v-model="queryParams.returnBeforeShipmentNumber"
            placeholder="请输入发货前退货数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发货前退货率" prop="returnBeforeShipmentRate">
          <el-input
            v-model="queryParams.returnBeforeShipmentRate"
            placeholder="请输入发货前退货率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发货后退货数" prop="returnAfterShipmentNumber">
          <el-input
            v-model="queryParams.returnAfterShipmentNumber"
            placeholder="请输入发货后退货数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="发货后退货率" prop="returnAfterShipmentRate">
          <el-input
            v-model="queryParams.returnAfterShipmentRate"
            placeholder="请输入发货后退货率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="总退货件数" prop="totalReturnNumber">
          <el-input
            v-model="queryParams.totalReturnNumber"
            placeholder="请输入总退货件数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="综合退货率" prop="comprehensiveReturnRate">
          <el-input
            v-model="queryParams.comprehensiveReturnRate"
            placeholder="请输入综合退货率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件销售数" prop="accessoriesSalesNumber">
          <el-input
            v-model="queryParams.accessoriesSalesNumber"
            placeholder="请输入配件销售数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件销售金额" prop="accessoriesSalesAmount">
          <el-input
            v-model="queryParams.accessoriesSalesAmount"
            placeholder="请输入配件销售金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件货单价" prop="accessoriesUnitPrice">
          <el-input
            v-model="queryParams.accessoriesUnitPrice"
            placeholder="请输入配件货单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品销售件数" prop="totalSoldNumber">
          <el-input
            v-model="queryParams.totalSoldNumber"
            placeholder="请输入商品销售件数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品销售总金额" prop="totalSoldAmount">
          <el-input
            v-model="queryParams.totalSoldAmount"
            placeholder="请输入商品销售总金额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品货单价" prop="unitPriceGoods">
          <el-input
            v-model="queryParams.unitPriceGoods"
            placeholder="请输入商品货单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="销售总毛利额" prop="totalGrossProfitSales">
          <el-input
            v-model="queryParams.totalGrossProfitSales"
            placeholder="请输入销售总毛利额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="订单数量" prop="totalOrdersNumber">
          <el-input
            v-model="queryParams.totalOrdersNumber"
            placeholder="请输入订单数量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="销售总成本" prop="totalCostAmount">
          <el-input
            v-model="queryParams.totalCostAmount"
            placeholder="请输入销售总成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="销售毛利" prop="salesGrossProfit">
          <el-input
            v-model="queryParams.salesGrossProfit"
            placeholder="请输入销售毛利"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="连带率" prop="jointSeveralRate">
          <el-input
            v-model="queryParams.jointSeveralRate"
            placeholder="请输入连带率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="客单价" prop="customerUnitPrice">
          <el-input
            v-model="queryParams.customerUnitPrice"
            placeholder="请输入客单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="货单价" prop="unitPrice">
          <el-input
            v-model="queryParams.unitPrice"
            placeholder="请输入货单价"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品销售总成本" prop="totalCostSales">
          <el-input
            v-model="queryParams.totalCostSales"
            placeholder="请输入商品销售总成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品平均销售成本" prop="averageCostSales">
          <el-input
            v-model="queryParams.averageCostSales"
            placeholder="请输入商品平均销售成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品平均销售毛利率" prop="averageSalesGrossProfit">
          <el-input
            v-model="queryParams.averageSalesGrossProfit"
            placeholder="请输入商品平均销售毛利率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品日常售价总额" prop="dailySellingPrice">
          <el-input
            v-model="queryParams.dailySellingPrice"
            placeholder="请输入商品日常售价总额"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="商品平均折扣率" prop="averageDiscountRateGoods">
          <el-input
            v-model="queryParams.averageDiscountRateGoods"
            placeholder="请输入商品平均折扣率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="赠品配件数" prop="complimentaryAccessoriesNumber">
          <el-input
            v-model="queryParams.complimentaryAccessoriesNumber"
            placeholder="请输入赠品配件数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="销售配件数" prop="salesAccessoriesNumber">
          <el-input
            v-model="queryParams.salesAccessoriesNumber"
            placeholder="请输入销售配件数"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件总消耗量" prop="accessoriesTotalConsumption">
          <el-input
            v-model="queryParams.accessoriesTotalConsumption"
            placeholder="请输入配件总消耗量"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件总成本" prop="accessoriesTotalCost">
          <el-input
            v-model="queryParams.accessoriesTotalCost"
            placeholder="请输入配件总成本"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件成本比率" prop="accessoriesCostRate">
          <el-input
            v-model="queryParams.accessoriesCostRate"
            placeholder="请输入配件成本比率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="配件消耗量比率" prop="accessoriesConsumptionRate">
          <el-input
            v-model="queryParams.accessoriesConsumptionRate"
            placeholder="请输入配件消耗量比率"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="支付日期" prop="payDate">
          <el-date-picker clearable v-model="queryParams.payDate" type="date" value-format="yyyy-MM-dd"
            placeholder="请选择支付日期">
          </el-date-picker>
        </el-form-item>
         -->
        <el-form-item label="支付日期-年" prop="payDateYear">
          <el-input
            v-model="queryParams.payDateYear"
            placeholder="请输入支付日期-年"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <el-form-item label="支付日期-月" prop="payDateMonth">
          <el-input
            v-model="queryParams.payDateMonth"
            placeholder="请输入支付日期-月"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="支付日期-日" prop="payDateDay">
          <el-input
            v-model="queryParams.payDateDay"
            placeholder="请输入支付日期-日"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item> -->
        <el-form-item label="业务日期-周" prop="payDateWeek">
          <el-input
            v-model="queryParams.payDateWeek"
            placeholder="请输入业务日期-周"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item>
        <!-- <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
          <el-input
            v-model="queryParams.isDelete"
            placeholder="请输入逻辑删除;0=未删除；1=已删除"
            clearable
            @keyup.enter.native="handleQuery"
          />
        </el-form-item> -->
      </div>
      <!-- <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item> -->
    </el-form>
    <el-dialog
      title="选择时间"
      :visible.sync="openInfo"
      width="700px"
      append-to-body
      v-if="openInfo"
    >
      <timeSearch
        @getDateArr="getDateArr"
        @changDay="changDay"
        :timeArr="timeArr"
        :dayActive="this.dayActive"
        :dayLimit="1095"
      />
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" size="mini" @click="handleRefreshCache">
          同步数据
        </el-button>
      </div>
    </el-dialog>

    <el-row :gutter="10" class="mb8">
      <el-col :span="1.5" style="display: none">
        <el-button
          type="primary"
          plain
          icon="el-icon-plus"
          size="mini"
          @click="handleAdd"
          v-hasPermi="['product:BiChannelSaleDwd:add']"
          >新增</el-button
        >
      </el-col>
      <el-col :span="1.5" style="display: none">
        <el-button
          type="success"
          plain
          icon="el-icon-edit"
          size="mini"
          :disabled="single"
          @click="handleUpdate"
          v-hasPermi="['product:BiChannelSaleDwd:edit']"
          >修改</el-button
        >
      </el-col>
      <el-col :span="1.5" style="display: none">
        <el-button
          type="danger"
          plain
          icon="el-icon-delete"
          size="mini"
          :disabled="multiple"
          @click="handleDelete"
          v-hasPermi="['product:BiChannelSaleDwd:remove']"
          >删除</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="warning"
          plain
          icon="el-icon-download"
          size="mini"
          @click="handleExport"
          v-hasPermi="['product:BiChannelSaleDwd:export']"
          >导出</el-button
        >
      </el-col>
      <el-col :span="1.5">
        <el-button
          type="danger"
          plain
          icon="el-icon-refresh"
          size="mini"
          @click="openInfo = true"
          >同步数据</el-button
        >
      </el-col>
      <right-toolbar
        :showSearch.sync="showSearch"
        @queryTable="getList"
      ></right-toolbar>
    </el-row>
    <div ref="tableDom">
      <el-table
        v-loading="loading"
        :maxHeight="BiChannelSaleDwdList.length ? tableHeight : 'auto'"
        :data="BiChannelSaleDwdList"
        @selection-change="handleSelectionChange"
        :row-class-name="tableRowClassName"
      >
        <!--  <el-table-column width="140" type="selection" width="55" align="center" />
       <el-table-column width="140" label="渠道销售明细ID" align="center" prop="id" /> -->
        <el-table-column
          width="140"
          label="品牌名称"
          align="center"
          prop="brand"
        />
        <el-table-column
          width="140"
          label="渠道名称"
          align="center"
          prop="channel"
        />
        <el-table-column
          width="140"
          label="支付日期-天"
          align="center"
          prop="payDay"
        >
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.payDay, "{y}-{m}-{d}") }}</span>
          </template>
        </el-table-column>
        <el-table-column
          width="140"
          label="销售金额"
          align="center"
          prop="salesAmount"
        />
        <el-table-column
          width="140"
          label="退款金额"
          align="center"
          prop="returnAmount"
        />
        <el-table-column
          width="140"
          label="净销售额"
          align="center"
          prop="netSalesAmount"
        />
        <el-table-column
          width="140"
          label="总销售件数"
          align="center"
          prop="totalSalesNumber"
        />
        <el-table-column
          width="140"
          label="发货前退货件数"
          align="center"
          prop="returnBeforeShipmentNumber"
        />
        <el-table-column
          width="140"
          label="发货前退货率"
          align="center"
          prop="returnBeforeShipmentRateStr"
        />
        <el-table-column
          width="140"
          label="发货后退货件数"
          align="center"
          prop="returnAfterShipmentNumber"
        />
        <el-table-column
          width="140"
          label="发货后退货率"
          align="center"
          prop="returnAfterShipmentRateStr"
        />
        <el-table-column
          width="140"
          label="总退货件数"
          align="center"
          prop="totalReturnNumber"
        />
        <el-table-column
          width="140"
          label="综合退货率"
          align="center"
          prop="comprehensiveReturnRateStr"
        />
        <el-table-column
          width="140"
          label="配件销售数"
          align="center"
          prop="accessoriesSalesNumber"
        />
        <el-table-column
          width="140"
          label="配件销售金额"
          align="center"
          prop="accessoriesSalesAmount"
        />
        <el-table-column
          width="140"
          label="配件货单价"
          align="center"
          prop="accessoriesUnitPriceStr"
        />
        <el-table-column
          width="140"
          label="商品总销售件数"
          align="center"
          prop="totalSoldNumber"
        />
        <el-table-column
          width="140"
          label="商品净销售件数"
          align="center"
          prop="totalNetSoldNumber"
        />
        <el-table-column
          width="140"
          label="商品销售总金额"
          align="center"
          prop="totalSoldAmount"
        />
        <el-table-column
          width="140"
          label="商品净销售总金额"
          align="center"
          prop="totalNetSoldAmount"
        >
          <template slot-scope="scope" v-if="scope.row.totalNetSoldAmount">
            <div>
              {{ scope.row.totalNetSoldAmount.toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          width="140"
          label="商品货单价"
          align="center"
          prop="unitPriceGoodsStr"
        />
        <!-- <el-table-column width="140" label="销售总毛利额" align="center" prop="totalGrossProfitSales" /> -->
        <el-table-column
          width="140"
          label="订单数量"
          align="center"
          prop="totalOrdersNumber"
        />
        <el-table-column
          width="140"
          label="销售净成本"
          align="center"
          prop="totalCostAmount"
        />
        <el-table-column
          width="140"
          label="净毛利"
          align="center"
          prop="salesGrossProfit"
        />
        <el-table-column
          width="140"
          label="连带率"
          align="center"
          prop="jointSeveralRate"
        >
          <template slot-scope="scope" v-if="scope.row.jointSeveralRate">
            <div>
              {{ scope.row.jointSeveralRate.toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          width="140"
          label="客单价"
          align="center"
          prop="customerUnitPriceStr"
        />
        <el-table-column
          width="140"
          label="货单价"
          align="center"
          prop="unitPrice"
        >
          <template slot-scope="scope" v-if="scope.row.unitPrice">
            <div>
              {{ scope.row.unitPrice.toFixed(2) }}
            </div>
          </template>
        </el-table-column>
        <el-table-column
          width="140"
          label="商品销售总成本"
          align="center"
          prop="totalCostSales"
        />
        <el-table-column
          width="140"
          label="商品平均销售成本"
          align="center"
          prop="averageCostSalesStr"
        />
        <el-table-column
          width="140"
          label="商品平均销售毛利率"
          align="center"
          prop="averageSalesGrossProfitStr"
        />

        <el-table-column
          width="140"
          label="商品日常售价总额"
          align="center"
          prop="dailySellingPrice"
        />

        <el-table-column
          width="140"
          label="商品日常售价净总额"
          align="center"
          prop="dailyNetSellingPrice"
        />

        <el-table-column
          width="140"
          label="商品平均折扣率"
          align="center"
          prop="averageDiscountRateGoodsStr"
        />
        <el-table-column
          width="140"
          label="赠品配件数"
          align="center"
          prop="complimentaryAccessoriesNumber"
        />
        <el-table-column
          width="140"
          label="销售配件数"
          align="center"
          prop="salesAccessoriesNumber"
        />
        <el-table-column
          width="140"
          label="配件总消耗量"
          align="center"
          prop="accessoriesTotalConsumption"
        />
        <el-table-column
          width="140"
          label="配件总成本"
          align="center"
          prop="accessoriesTotalCost"
        />
        <el-table-column
          width="140"
          label="配件成本比率"
          align="center"
          prop="accessoriesCostRateStr"
        />
        <el-table-column
          width="140"
          label="配件消耗量比率"
          align="center"
          prop="accessoriesConsumptionRateStr"
        />
        <!-- <el-table-column width="140" label="支付日期" align="center" prop="payDate">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.payDate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column> -->

        <el-table-column
          width="140"
          label="支付日期-年"
          align="center"
          prop="payDateYear"
        />
        <el-table-column
          width="140"
          label="支付日期-月"
          align="center"
          prop="payDateMonth"
        />
        <el-table-column
          width="140"
          label="支付日期-日"
          align="center"
          prop="payDateDay"
        />
        <el-table-column
          width="140"
          label="业务日期-周"
          align="center"
          prop="payDateWeek"
        />
      </el-table>
    </div>

    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />

    <!-- 添加或修改T6渠道销售总览日报对话框 -->
    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
      <el-form ref="form" :model="form" :rules="rules" label-width="80px">
        <el-form-item label="渠道名称" prop="channel">
          <el-input v-model="form.channel" placeholder="请输入渠道名称" />
        </el-form-item>
        <el-form-item label="销售金额" prop="salesAmount">
          <el-input v-model="form.salesAmount" placeholder="请输入销售金额" />
        </el-form-item>
        <el-form-item label="退款金额" prop="returnAmount">
          <el-input v-model="form.returnAmount" placeholder="请输入退款金额" />
        </el-form-item>
        <el-form-item label="净销售额" prop="netSalesAmount">
          <el-input
            v-model="form.netSalesAmount"
            placeholder="请输入净销售额"
          />
        </el-form-item>
        <el-form-item label="商品销售总金额" prop="totalSalesNumber">
          <el-input
            v-model="form.totalSalesNumber"
            placeholder="请输入商品销售总金额"
          />
        </el-form-item>
        <el-form-item label="发货前退货数" prop="returnBeforeShipmentNumber">
          <el-input
            v-model="form.returnBeforeShipmentNumber"
            placeholder="请输入发货前退货数"
          />
        </el-form-item>
        <el-form-item label="发货前退货率" prop="returnBeforeShipmentRate">
          <el-input
            v-model="form.returnBeforeShipmentRate"
            placeholder="请输入发货前退货率"
          />
        </el-form-item>
        <el-form-item label="发货后退货数" prop="returnAfterShipmentNumber">
          <el-input
            v-model="form.returnAfterShipmentNumber"
            placeholder="请输入发货后退货数"
          />
        </el-form-item>
        <el-form-item label="发货后退货率" prop="returnAfterShipmentRate">
          <el-input
            v-model="form.returnAfterShipmentRate"
            placeholder="请输入发货后退货率"
          />
        </el-form-item>
        <el-form-item label="总退货件数" prop="totalReturnNumber">
          <el-input
            v-model="form.totalReturnNumber"
            placeholder="请输入总退货件数"
          />
        </el-form-item>
        <el-form-item label="综合退货率" prop="comprehensiveReturnRate">
          <el-input
            v-model="form.comprehensiveReturnRate"
            placeholder="请输入综合退货率"
          />
        </el-form-item>
        <el-form-item label="配件销售数" prop="accessoriesSalesNumber">
          <el-input
            v-model="form.accessoriesSalesNumber"
            placeholder="请输入配件销售数"
          />
        </el-form-item>
        <el-form-item label="配件销售金额" prop="accessoriesSalesAmount">
          <el-input
            v-model="form.accessoriesSalesAmount"
            placeholder="请输入配件销售金额"
          />
        </el-form-item>
        <el-form-item label="配件货单价" prop="accessoriesUnitPrice">
          <el-input
            v-model="form.accessoriesUnitPrice"
            placeholder="请输入配件货单价"
          />
        </el-form-item>
        <el-form-item label="商品销售件数" prop="totalSoldNumber">
          <el-input
            v-model="form.totalSoldNumber"
            placeholder="请输入商品销售件数"
          />
        </el-form-item>
        <el-form-item label="商品销售总金额" prop="totalSoldAmount">
          <el-input
            v-model="form.totalSoldAmount"
            placeholder="请输入商品销售总金额"
          />
        </el-form-item>
        <el-form-item label="商品货单价" prop="unitPriceGoods">
          <el-input
            v-model="form.unitPriceGoods"
            placeholder="请输入商品货单价"
          />
        </el-form-item>
        <el-form-item label="销售总毛利额" prop="totalGrossProfitSales">
          <el-input
            v-model="form.totalGrossProfitSales"
            placeholder="请输入销售总毛利额"
          />
        </el-form-item>
        <el-form-item label="订单数量" prop="totalOrdersNumber">
          <el-input
            v-model="form.totalOrdersNumber"
            placeholder="请输入订单数量"
          />
        </el-form-item>
        <el-form-item label="销售总成本" prop="totalCostAmount">
          <el-input
            v-model="form.totalCostAmount"
            placeholder="请输入销售总成本"
          />
        </el-form-item>
        <el-form-item label="销售毛利" prop="salesGrossProfit">
          <el-input
            v-model="form.salesGrossProfit"
            placeholder="请输入销售毛利"
          />
        </el-form-item>
        <el-form-item label="连带率" prop="jointSeveralRate">
          <el-input
            v-model="form.jointSeveralRate"
            placeholder="请输入连带率"
          />
        </el-form-item>
        <el-form-item label="客单价" prop="customerUnitPrice">
          <el-input
            v-model="form.customerUnitPrice"
            placeholder="请输入客单价"
          />
        </el-form-item>
        <el-form-item label="货单价" prop="unitPrice">
          <el-input v-model="form.unitPrice" placeholder="请输入货单价" />
        </el-form-item>
        <el-form-item label="商品销售总成本" prop="totalCostSales">
          <el-input
            v-model="form.totalCostSales"
            placeholder="请输入商品销售总成本"
          />
        </el-form-item>
        <el-form-item label="商品平均销售成本" prop="averageCostSalesStr">
          <el-input
            v-model="form.averageCostSalesStr"
            placeholder="请输入商品平均销售成本"
          />
        </el-form-item>
        <el-form-item label="商品平均销售毛利率" prop="averageSalesGrossProfit">
          <el-input
            v-model="form.averageSalesGrossProfit"
            placeholder="请输入商品平均销售毛利率"
          />
        </el-form-item>
        <el-form-item label="商品日常售价总额" prop="dailySellingPrice">
          <el-input
            v-model="form.dailySellingPrice"
            placeholder="请输入商品日常售价总额"
          />
        </el-form-item>
        <el-form-item label="商品平均折扣率" prop="averageDiscountRateGoods">
          <el-input
            v-model="form.averageDiscountRateGoods"
            placeholder="请输入商品平均折扣率"
          />
        </el-form-item>
        <el-form-item label="赠品配件数" prop="complimentaryAccessoriesNumber">
          <el-input
            v-model="form.complimentaryAccessoriesNumber"
            placeholder="请输入赠品配件数"
          />
        </el-form-item>
        <el-form-item label="销售配件数" prop="salesAccessoriesNumber">
          <el-input
            v-model="form.salesAccessoriesNumber"
            placeholder="请输入销售配件数"
          />
        </el-form-item>
        <el-form-item label="配件总消耗量" prop="accessoriesTotalConsumption">
          <el-input
            v-model="form.accessoriesTotalConsumption"
            placeholder="请输入配件总消耗量"
          />
        </el-form-item>
        <el-form-item label="配件总成本" prop="accessoriesTotalCost">
          <el-input
            v-model="form.accessoriesTotalCost"
            placeholder="请输入配件总成本"
          />
        </el-form-item>
        <el-form-item label="配件成本比率" prop="accessoriesCostRate">
          <el-input
            v-model="form.accessoriesCostRate"
            placeholder="请输入配件成本比率"
          />
        </el-form-item>
        <el-form-item label="配件消耗量比率" prop="accessoriesConsumptionRate">
          <el-input
            v-model="form.accessoriesConsumptionRate"
            placeholder="请输入配件消耗量比率"
          />
        </el-form-item>
        <el-form-item label="支付日期" prop="payDate">
          <el-date-picker
            clearable
            v-model="form.payDate"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择支付日期"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="支付日期-天" prop="payDay">
          <el-date-picker
            clearable
            v-model="form.payDay"
            type="date"
            value-format="yyyy-MM-dd"
            placeholder="请选择支付日期-天"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item label="支付日期-年" prop="payDateYear">
          <el-input
            v-model="form.payDateYear"
            placeholder="请输入支付日期-年"
          />
        </el-form-item>
        <el-form-item label="支付日期-月" prop="payDateMonth">
          <el-input
            v-model="form.payDateMonth"
            placeholder="请输入支付日期-月"
          />
        </el-form-item>
        <el-form-item label="支付日期-日" prop="payDateDay">
          <el-input v-model="form.payDateDay" placeholder="请输入支付日期-日" />
        </el-form-item>
        <el-form-item label="业务日期-周" prop="payDateWeek">
          <el-input
            v-model="form.payDateWeek"
            placeholder="请输入业务日期-周"
          />
        </el-form-item>
        <el-form-item label="逻辑删除;0=未删除；1=已删除" prop="isDelete">
          <el-input
            v-model="form.isDelete"
            placeholder="请输入逻辑删除;0=未删除；1=已删除"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="submitForm">确 定</el-button>
        <el-button @click="cancel">取 消</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import timeSearch from "./day.vue";
import {
  listBiChannelSaleDwd,
  getBiChannelSaleDwd,
  delBiChannelSaleDwd,
  addBiChannelSaleDwd,
  updateBiChannelSaleDwd,
  synchroChannelData,
} from "@/api/chart/BiChannelSaleDwd";
import moment from "moment";
export default {
  name: "BiChannelSaleDwd",
  components: { timeSearch },
  data() {
    const end = new Date();
    const start = new Date();
    start.setTime(start.getTime() - 30 * 24 * 60 * 60 * 1000); // 30天前
    return {
      openInfo: false,
      dayActive: 30,
      timeArr: [
        { value: "2", label: "昨天" },
        { value: "7", label: "最近7天" },
        { value: "30", label: "最近30天" },
        { value: "365", label: "最近一年" },
        { value: "1", label: "日" },
      ],
      timeGap: { startTime: "", endTime: "" },
      isOpen: false,
      //纵向滚动条
      tableHeight: "",
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // T6渠道销售总览日报表格数据
      BiChannelSaleDwdList: [],
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        channel: null,
        salesAmount: null,
        returnAmount: null,
        netSalesAmount: null,
        totalSalesNumber: null,
        returnBeforeShipmentNumber: null,
        returnBeforeShipmentRate: null,
        returnAfterShipmentNumber: null,
        returnAfterShipmentRate: null,
        totalReturnNumber: null,
        comprehensiveReturnRate: null,
        accessoriesSalesNumber: null,
        accessoriesSalesAmount: null,
        accessoriesUnitPrice: null,
        totalSoldNumber: null,
        totalSoldAmount: null,
        unitPriceGoods: null,
        totalGrossProfitSales: null,
        totalOrdersNumber: null,
        totalCostAmount: null,
        salesGrossProfit: null,
        jointSeveralRate: null,
        customerUnitPrice: null,
        unitPrice: null,
        totalCostSales: null,
        averageCostSales: null,
        averageSalesGrossProfit: null,
        dailySellingPrice: null,
        averageDiscountRateGoods: null,
        complimentaryAccessoriesNumber: null,
        salesAccessoriesNumber: null,
        accessoriesTotalConsumption: null,
        accessoriesTotalCost: null,
        accessoriesCostRate: null,
        accessoriesConsumptionRate: null,
        payDate: null,
        payDay: null,
        payDateYear: null,
        payDateMonth: null,
        payDateDay: null,
        payDateWeek: null,
        isDelete: null,
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        channel: [
          { required: true, message: "渠道名称不能为空", trigger: "blur" },
        ],
      },
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            },
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            },
          },
        ],
      },
      value1: "",
      value2: [start, end], // 默认选中最近30天
    };
  },
  created() {
    this.changeTime();
  },
  mounted() {
    var _this = this;
    this.resizeTable();
    window.onresize = function () {
      _this.resizeTable();
    };
  },
  //记得清空  如果在keepalive中 则使用activated  deactivated
  destroyed() {
    window.onresize = null;
  },
  methods: {
    changeTime() {
      // console.log(JSON.stringify(this.value2));
      let m1 = moment(this.value2[0]).format("YYYY-MM-DD");
      let m2 = moment(this.value2[1]).format("YYYY-MM-DD");
      // console.log(JSON.stringify(m1));
      // console.log(JSON.stringify(m2));
      this.queryParams.payDayStart = m1;
      this.queryParams.payDayEnd = m2;
      this.getList();
      // this.queryParams.startDate = m1;
      // this.queryParams.endDate = m2;
    },
    tableRowClassName({ row, rowIndex }) {
      // return "font-weight: bold;";
      if (row.brand === "汇总") {
        return "highlight-row";
      } else {
        return "";
      }
    },
    /** 刷新缓存按钮操作 Warning*/
    handleRefreshCache() {
      this.$modal.msgWarning("数据正在同步，请稍候");
      const obj = {
        startDate: this.timeGap.startTime,
        endDate: this.timeGap.endTime,
      };
      synchroChannelData(obj).then(() => {
        this.$modal.msgSuccess("同步数据成功");
        this.getList();
        this.openInfo = false;
        // this.$store.dispatch('dict/cleanDict');
      });
    },
    //时间控件
    changDay(val) {
      this.dayActive = val;
      this.timeGap.startTime = val[0];
      this.timeGap.endTime = val[1];
    },
    getDateArr(value) {
      this.timeGap.startTime = value[0];
      this.timeGap.endTime = value[1];
      console.log(JSON.stringify(this.timeGap));
      this.queryParams.payDayStart = this.timeGap.startTime;
      this.queryParams.payDayEnd = this.timeGap.endTime;

      this.getList();

      this.dayActive = 1;
    },
    //搜索栏展示与收起
    shouqi() {
      // console.log(1);
      this.isOpen = !this.isOpen;
    },
    /** 查询T6渠道销售总览日报列表 */
    getList() {
      this.loading = true;
      listBiChannelSaleDwd(this.queryParams).then((response) => {
        this.BiChannelSaleDwdList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        channel: null,
        salesAmount: null,
        returnAmount: null,
        netSalesAmount: null,
        totalSalesNumber: null,
        returnBeforeShipmentNumber: null,
        returnBeforeShipmentRate: null,
        returnAfterShipmentNumber: null,
        returnAfterShipmentRate: null,
        totalReturnNumber: null,
        comprehensiveReturnRate: null,
        accessoriesSalesNumber: null,
        accessoriesSalesAmount: null,
        accessoriesUnitPrice: null,
        totalSoldNumber: null,
        totalSoldAmount: null,
        unitPriceGoods: null,
        totalGrossProfitSales: null,
        totalOrdersNumber: null,
        totalCostAmount: null,
        salesGrossProfit: null,
        jointSeveralRate: null,
        customerUnitPrice: null,
        unitPrice: null,
        totalCostSales: null,
        averageCostSales: null,
        averageSalesGrossProfit: null,
        dailySellingPrice: null,
        averageDiscountRateGoods: null,
        complimentaryAccessoriesNumber: null,
        salesAccessoriesNumber: null,
        accessoriesTotalConsumption: null,
        accessoriesTotalCost: null,
        accessoriesCostRate: null,
        accessoriesConsumptionRate: null,
        payDate: null,
        payDay: null,
        payDateYear: null,
        payDateMonth: null,
        payDateDay: null,
        payDateWeek: null,
        isDelete: null,
        createBy: null,
        createTime: null,
        updateBy: null,
        updateTime: null,
      };
      this.resetForm("form");
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams = {};
      this.value2 = [];
      this.queryParams.pageSize = 10;
      this.handleQuery();
    },
    // 多选框选中数据
    handleSelectionChange(selection) {
      this.ids = selection.map((item) => item.id);
      this.single = selection.length !== 1;
      this.multiple = !selection.length;
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加T6渠道销售总览日报";
    },
    /** 修改按钮操作 */
    handleUpdate(row) {
      this.reset();
      const id = row.id || this.ids;
      getBiChannelSaleDwd(id).then((response) => {
        this.form = response.data;
        this.open = true;
        this.title = "修改T6渠道销售总览日报";
      });
    },
    /** 提交按钮 */
    submitForm() {
      this.$refs["form"].validate((valid) => {
        if (valid) {
          if (this.form.id != null) {
            updateBiChannelSaleDwd(this.form).then((response) => {
              this.$modal.msgSuccess("修改成功");
              this.open = false;
              this.getList();
            });
          } else {
            addBiChannelSaleDwd(this.form).then((response) => {
              this.$modal.msgSuccess("新增成功");
              this.open = false;
              this.getList();
            });
          }
        }
      });
    },
    /** 删除按钮操作 */
    handleDelete(row) {
      const ids = row.id || this.ids;
      this.$modal
        .confirm('是否确认删除T6渠道销售总览日报编号为"' + ids + '"的数据项？')
        .then(function () {
          return delBiChannelSaleDwd(ids);
        })
        .then(() => {
          this.getList();
          this.$modal.msgSuccess("删除成功");
        })
        .catch(() => {});
    },
    /** 导出按钮操作 */
    handleExport() {
      this.download(
        "product/BiChannelSaleDwd/export",
        {
          ...this.queryParams,
        },
        `BiChannelSaleDwd_${new Date().getTime()}.xlsx`
      );
    },
    // table自动高度
    returnTableHeight(ref, bottomOffset) {
      let height = null;
      height =
        window.innerHeight - ref.getBoundingClientRect().top - bottomOffset;
      return height;
    },

    resizeTable() {
      this.$nextTick(() => {
        this.tableHeight = this.returnTableHeight(this.$refs.tableDom, 100);
      }, 0);
    },
  },
};
</script>
<style lang="scss" >
/* 添加你想要的特定行的CSS样式 */
.highlight-row {
  position: sticky;
  bottom: 0;
  font-weight: bold;
}
</style>
